/////////////////////////////////////////////////////////////////////////////
/*/	
 *	Creator:		Joshua C. Rouzer
 *	Title:			Base Class cpp
 *	Last Edited:	06/14/2013
 *	Summary:		Function definition for base class units
/*/
/////////////////////////////////////////////////////////////////////////////
#include "BaseClass.h"
#include "CSGD_TextureManager.h"
#include <cassert>
/////////////////////////////////////////////////////////////////////////////
// Function : Default Constructor
// Notes	: Gives default values to the unit variables
/////////////////////////////////////////////////////////////////////////////
CBaseClass::CBaseClass(){
	m_eType = BASIC;
	m_nImage = -1;
	m_fRotation = 0.0f;
	m_sPos.m_nPosX = 0.0f;
	m_sPos.m_nPosY = 0.0f;
	m_nWidth = 0;
	m_nHeight = 0;
	m_nTeam = 0;

	AnimSystem = nullptr;
	AnimationInfo = nullptr;
	CurrAnim = nullptr;
}
/////////////////////////////////////////////////////////////////////////////
// Function		: Constructor
// Parameters	: filename - the filepath to load the texture from
//					nWidth - the width of the texture unit
//					nHeight - the height of the texture unit
//					fPosX - a starting X position
//					fPosY - a starting Y position
// Notes		: Provides starting values to the unit variables
/////////////////////////////////////////////////////////////////////////////
CBaseClass::CBaseClass(TCHAR filename, int nWidth, int nHeight, float fPosX, float fPosY){
	m_nImage = -1;
	m_nImage = CSGD_TextureManager::GetInstance()->LoadTexture(&filename);
	m_sPos.m_nPosX = fPosX;
	m_sPos.m_nPosY = fPosY;
	m_nWidth = nWidth;
	m_nHeight = nHeight;
	m_fRotation = 0.0f;
}

CBaseClass::CBaseClass(TCHAR filename, int nWidth, int nHeight, SPosition sPos){
	m_nImage = -1;
	m_nImage = CSGD_TextureManager::GetInstance()->LoadTexture(&filename);
	m_sPos = sPos;
	m_nWidth = nWidth;
	m_nHeight = nHeight;
	m_fRotation = 0.0f;
}
/////////////////////////////////////////////////////////////////////////////
// Function		: Destructor
// Notes		: Cleans up any dynamical allocated memory
/////////////////////////////////////////////////////////////////////////////
CBaseClass::~CBaseClass(){
	if( m_nImage != -1 )
	CSGD_TextureManager::GetInstance()->UnloadTexture(m_nImage);
}
/////////////////////////////////////////////////////////////////////////////
// Function		: Update
// Parameters	: dT - Time elapsed since last update
// Notes		: Updates the variables based on the time parameter
/////////////////////////////////////////////////////////////////////////////
void CBaseClass::Update(float dT){
	//Base class cannot/doesn't change position
}
/////////////////////////////////////////////////////////////////////////////
// Function		: Render
// Notes		: Renders the object to the screen at it's position
/////////////////////////////////////////////////////////////////////////////
void CBaseClass::Render(){
	//CSGD_TextureManager::GetInstance()->Draw(m_nImage, (int)m_sPos.m_nPosX, (int)m_sPos.m_nPosY);
	RECT rect;
	SetRect(&rect, 0, 0, m_nWidth, m_nHeight);
	CSGD_TextureManager::GetInstance()->Draw(m_nImage, (int)m_sPos.m_nPosX, (int)m_sPos.m_nPosY, 
		1.0f, 1.0f, &rect, GetWidth() / 2.0f, GetHeight() / 2.0f, D3DX_PI * GetRotation());
}
/////////////////////////////////////////////////////////////////////////////
// Function		: Get RECT
// Notes		: Returns the collision RECT for the object
/////////////////////////////////////////////////////////////////////////////
RECT CBaseClass::GetRect(){
	RECT rect;
	//SetRect(&rect, (int)m_fPosX, (int)m_fPosY, (int)m_fPosX + m_nWidth, (int)m_fPosY + m_nHeight);
	SetRect(&rect, (int)m_sPos.m_nPosX, (int)m_sPos.m_nPosY, (int)m_sPos.m_nPosX + m_nWidth, (int)m_sPos.m_nPosY + m_nHeight);
	return rect;
}
